/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mapper;


import beans.OtherBean;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

/**
 *
 * @author Haomaru
 */
public class OtherMapper extends DBMapper{
     public OtherMapper() throws Exception {
        super();
    }

    public OtherBean getotherInformation(String ID) throws Exception {
        OtherBean otherBean = new OtherBean();

        try {
            StringBuffer sql = new StringBuffer();
            sql.append("SELECT * FROM Other WHERE ");
            sql.append(" ID = '" + ID + "'");

            PreparedStatement stmt = getConnection().prepareStatement(sql.toString());
            ResultSet rs = stmt.executeQuery();
            if ((rs != null) && rs.next()) {
                initOtherBean(otherBean, rs);
            }

            stmt.close();
        } catch (Exception e) {
            throw e;
        }

        return otherBean;
    }

    public void insertNewother(OtherBean other) throws Exception {
        try {
            StringBuffer sql = new StringBuffer();
            PreparedStatement stmt = getConnection().prepareStatement(sql.toString());
            //...
            stmt.execute();
            stmt.close();
        } catch (Exception e) {
            throw e;
        }
    }

    public void initOtherBean(OtherBean otherBean, ResultSet rs) throws Exception {
        if ((rs != null) && (otherBean != null)) {
            otherBean.setID(rs.getString("id"));
            otherBean.setTitle(rs.getString("title"));
            otherBean.setContent(rs.getString("content"));
        }
    }
}
